package cn.wolfcode.controller;

import cn.wolfcode.domain.JsonResult;
import cn.wolfcode.qo.QueryObject;
import cn.wolfcode.service.IPermissionService;
import cn.wolfcode.util.RequiredPermission;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/permission")
public class PermissionController {
IPermissionService service;
@Autowired
    public void setService(IPermissionService service) {
        this.service = service;
    }
@RequestMapping("/list")
    public String list(QueryObject qo, Model model){
        PageInfo pageInfo = service.query(qo);
        model.addAttribute("PageInfo",pageInfo);
        return "permission/list";
}
@RequiredPermission(name="重新加载",expression = "permission/reload")
@RequestMapping("/reload")
@ResponseBody
public JsonResult reload(){
 service.reload();
 return new JsonResult();
}
}
